package com.xinqi.modules.prepare.common.utils;

import com.xinqi.common.base.error.CommonErrors;
import com.xinqi.modules.prepare.common.domain.PrepareBaseParam;
import com.xinqi.modules.prepare.courseware.domain.PrepareCoursewareEntity;
import com.xinqi.modules.prepare.data.domain.PrepareDataEntity;
import com.xinqi.modules.prepare.discuss.domain.PrepareDiscussEntity;
import com.xinqi.modules.prepare.folder.domain.PrepareFileFolderEntity;
import com.xinqi.modules.prepare.homework.domain.PrepareHomeworkEntity;
import com.xinqi.modules.prepare.notice.domain.PrepareNoticeEntity;
import com.xinqi.modules.prepare.paper.domain.PrepareExamPaperEntity;
import com.xinqi.modules.prepare.prepare.domain.PrepareMemberEntity;
import com.xinqi.modules.prepare.prepare.domain.PrepareOperateLogEntity;
import com.xinqi.modules.prepare.prepare.enums.PrepareTypeEnum;
import com.xinqi.modules.prepare.question.domain.PrepareQuestionBankEntity;
import com.xinqi.modules.prepare.video.domain.PrepareVideoEntity;

/**
 * @author linkai
 * @date 2023/3/24
 */
public interface PrepareTypeUtils {

    static PrepareTypeEnum get(PrepareBaseParam obj) {

        if (obj instanceof PrepareDataEntity) {
            // 资料
            return PrepareTypeEnum.DATA;
        } else if (obj instanceof PrepareDiscussEntity) {
            // 讨论
            return PrepareTypeEnum.DISCUSS;
        } else if (obj instanceof PrepareNoticeEntity) {
            // 公告
            return PrepareTypeEnum.NOTICE;
        } else if (obj instanceof PrepareHomeworkEntity) {
            // 作业
            return PrepareTypeEnum.HOMEWORK;
        } else if (obj instanceof PrepareExamPaperEntity) {
            // 测评
            return PrepareTypeEnum.PAPER;
        } else if (obj instanceof PrepareVideoEntity) {
            // 互动课件
            return PrepareTypeEnum.INTERACT_VIDEO;
        } else if (obj instanceof PrepareQuestionBankEntity) {
            // 试题库
            return PrepareTypeEnum.QUESTION_BANK;
        } else if (obj instanceof PrepareCoursewareEntity) {
            // 互动视频
            return PrepareTypeEnum.INTERACT_COURSEWARE;
        } else if (obj instanceof PrepareMemberEntity) {
            // 成员
            return PrepareTypeEnum.MEMBER;
        } else if (obj instanceof PrepareFileFolderEntity) {
            // 文件
            return PrepareTypeEnum.FOLDER;
        } else if (obj instanceof PrepareOperateLogEntity) {
            // 操作日志
            return PrepareTypeEnum.LOG;
        }
        throw CommonErrors.BAD_REQUEST.asException("类型错误");
    }
}
